home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 October / october_2001.iso / Site Building / Html Notes 1.19 / HTMNOTES.EXE / file0021.bin < prev    next >
Encoding:
Text File  |  2001-08-18  |  1015 b   |  40 lines

  1. <SCRIPT LANGUAGE="JavaScript">
  2. <!--  Clock --
  3.  
  4. var timerID = null
  5. var timerRunning = false
  6.  
  7. function stopclock(){
  8.     if(timerRunning)
  9.         clearTimeout(timerID)
  10.     timerRunning = false
  11. }
  12.  
  13. function startclock(){
  14.     stopclock()
  15.     showtime()
  16. }
  17.  
  18. function showtime(){
  19.     var now = new Date()
  20.     var hours = now.getHours()
  21.     var minutes = now.getMinutes()
  22.     var seconds = now.getSeconds()
  23.     var timeValue = "" + ((hours > 12) ? hours - 12 : hours)
  24.     timeValue  += ((minutes < 10) ? ":0" : ":") + minutes
  25.     timeValue  += ((seconds < 10) ? ":0" : ":") + seconds
  26.     timeValue  += (hours >= 12) ? " P.M." : " A.M."
  27.     document.clock.face.value = timeValue 
  28.     timerID = setTimeout("showtime()",1000)
  29.     timerRunning = true
  30. }
  31. //-->
  32. </SCRIPT>
  33.  
  34. <BODY onLoad="startclock()">
  35.  
  36. <!--------------------------------------------------------------------------->
  37. <form name="clock" onSubmit="0">
  38. <INPUT TYPE="text" NAME="face" SIZE=11 VALUE ="....Initializing....">
  39. </form>
  40.